<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        function add(a,b) {
            return a+b;
        }


        const createProxyFactory = function (fn) {
            let cache = {};
            return function () {
                let args = Array.prototype.join.call(arguments, ',');
                if (args in cache) {
                    return cache[args];
                }
                return cache[args] = fn.apply(this, arguments);
            }
        }

        let addProxy = createProxyFactory(add);
        console.log(addProxy(10,20));
    </script>
</body>

</html>